﻿var fnCheck = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    var vid = record.getData("ID");
    if (vid != "" && !(vid == undefined || vid == "undefined")) {
        if (confirm("您确认该条佣金吗？")) {
            var SaveUrl = "AjaxData/CustomOperating.aspx" + "?r=" + Math.random() + "&type=1&action=update&entity=CrmCommisionExtend&id=" + vid;
            YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
                success: function (res) {
                    try {
                        var str = res.responseText;
                        if (str == "1") {
                            YAHOO.example.container.dialog3.hide();
                            alert("操作成功!");
                           // RefreshData();
                            return;
                        } else {
                            alert(str);
                        }
                    }
                    catch (e) {
                    }
                    finally {
                    }
                },
                failure: function (error) {
                    alert("数据错误：" + error.statusText);
                }
            }, null);
        }
    } else {
        alert("数据有误");
    }
}

var fnCancel = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    var vid = record.getData("ID");
    if (vid != "" && !(vid == undefined || vid == "undefined")) {
        if (confirm("您确认该条佣金吗？")) {
            var SaveUrl = "AjaxData/CustomOperating.aspx" + "?r=" + Math.random() + "&type=0&action=update&entity=CrmCommisionExtend&id=" + vid;
            YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
                success: function (res) {
                    try {
                        var str = res.responseText;
                        if (str == "1") {
                            YAHOO.example.container.dialog3.hide();
                            alert("操作成功!");
                           // RefreshData();
                            return;
                        } else {
                            alert(str);
                        }
                    }
                    catch (e) {
                    }
                    finally {
                    }
                },
                failure: function (error) {
                    alert("数据错误：" + error.statusText);
                }
            }, null);
        }
    } else {
        alert("数据有误");
    }
}

var fnBargain = function () {

    var SetManagerURL = "../../Crm/Modules/AddCommission.aspx?r=";

    document.getElementById("EditUIWindow").src = SetManagerURL + Math.random() + "&entity=CrmCommisionExtend&id=1";
    YAHOO.example.container.dialog1.show();
    document.getElementById("yui-gen31-button").style.display = "block";


};